<?php


namespace app\index\model;


use think\Model;

class OrderItemDetail extends Model
{
    public static function getOrderItemDetailByOrderId($id){
        $OrderClass=new Order();
        $order_detail_data=$OrderClass->alias('o')
            ->join('order_item oi','o.id=oi.order_id','left')
            ->join('order_item_detail oid','oi.id=oid.order_item_id and oid.del_flag=0','left')
            ->where('o.id',$id)
            ->where('o.del_flag',0)
            ->where('oi.del_flag',0)
            ->field('oid.id,oid.order_item_id,oid.pro_id,oid.en_name,oid.cn_name,oid.pur_price,oid.amount,oid.type,oid.weight,oid.demand_stock,oid.lock_quantity,oid.lock_status,oid.remark')
            ->select()
            ->toArray();
        $order_item_detail=[];
        foreach ($order_detail_data as $key=>$value){
            $order_item_detail[$value['order_item_id']][]=$value;
        }
        return $order_item_detail;
    }

}